<template>
  <div>
    <el-form
      ref="form"
      :rules="rules"
      :model="form"
      label-width="120px"
      label-position="left"
    >
      <el-form-item label="会员ID:" prop="id">
        <el-select
          v-model="form.id"
          style="width: 100%"
          placeholder="请选择会员ID"
        >
          <el-option
            v-for="(item, index) in levelList"
            :key="index"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item v-if="isadd"  label="类型:" prop="status">
        <el-radio-group v-model="form.status">
          <el-radio :label="1">充值</el-radio>
          <el-radio :label="0">扣款</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="变更金额:" prop="money">
        <el-input v-model="form.money" type="number" placeholder="请输入变更金额"></el-input>
      </el-form-item>
      <el-form-item label="变更前余额:" prop="money">
        <el-input v-model="form.money" type="number" placeholder="请输入变更前余额"></el-input>
      </el-form-item>
      <el-form-item label="变更后余额:" prop="money">
        <el-input v-model="form.money" type="number" placeholder="请输入变更后余额"></el-input>
      </el-form-item>
      <el-form-item label="商品:" prop="goods">
        <el-input v-model="form.goods" placeholder="请输入商品"></el-input>
      </el-form-item>
      <el-form-item label="资金流水单号:" prop="order">
        <el-input v-model="form.order" placeholder="请输入资金流水单号"></el-input>
      </el-form-item>
    </el-form>
    <div class="flexend">
      <el-button type="primary" @click="onSubmit">确 认</el-button>
      <el-button @click="handleClose">取 消</el-button>
    </div>
  </div>
</template>

<script>
import { validPhone } from "@/utils/validate";
export default {
  data() {
    return {
      levelList: [
        { label: "免费版", value: 1 },
        { label: "专业版", value: 2 },
        { label: "旗舰版", value: 3 },
      ],
      form: {
        id: "",
        money: "",
        goods: "",
        order: "",
        status: 1,
      },
      rules: {
        id: [
          { required: true, message: "请选择会员id", trigger: "change" }
        ],
        money: [{ required: true, message: "请输入变更金额", trigger: "blur" }],
        goods: [{ required: true, message: "请输入商品", trigger: "blur" }],
        order: [
          { required: true, message: "请输入资金流水单号", trigger: "blur" },
        ],
        status: [{ required: true, message: "请选择状态", trigger: "change" }],
      },
    };
  },
  props:{
    isadd:{
       type:Boolean,
       default:true
    }
  },
  methods: {
    onSubmit() {
      this.$refs.form.validate((valid) => {
        if (!valid) return;
      });
    },

    resetForm() {
      this.$refs.form.resetFields();
    },

    handleClose(){
        this.$emit('close')
    }
  },
};
</script>